#include <func.h>
#define NUM 2
int e=8;
void *thfunc(void*p)
{
    pthread_mutex_t *pmutex=(pthread_mutex_t*)p;
    printf("I am subthread\n");
    pthread_mutex_lock(pmutex);
    printf("get e\n");
    printf("e=%d\n",++e);
    sleep(6);
    printf("e=%d\n",++e);
    pthread_mutex_unlock(pmutex);

}
int main(int argc,char *argv[])
{
    pthread_t pthid[NUM];
    pthread_mutex_t mutex;
    pthread_mutex_init(&mutex,NULL);
    for(int i=0;i<NUM;++i)
    {
        pthread_create(pthid+i,NULL,thfunc,&mutex);
    }
    while(1);
    return 0;
}

